<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.model.Fault"%>
<%@ page import="com.control.FaultControl"%>
<%@ page import="com.util.PageResultSet" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>管理员查看报修信息</title>
	</head>
	<body>
		<%
	    	request.setCharacterEncoding("utf-8");
	    	String ToolBar = "";
	    	int curPage = 1;
	    	if(request.getParameter("cur_page")!= null) {
				curPage = Integer.parseInt(request.getParameter("cur_page")); 
			}
	    	boolean flag = false;
	    	if(request.getParameter("chuli")!=null){
	    		flag = Boolean.parseBoolean(request.getParameter("chuli"));
	    		session.setAttribute("flag",flag);
	    	}
		%>
		<table width="98%" border="0" align="center">
			<tr>
				<td></td>
			</tr>
			<tr>
				<td></td>
			</tr>
			<tr>
				<td>
					<fieldset>
						<legend>
							查看报修
						</legend>
						<form action="fault_show.jsp" name="form1" method="post">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
								<tr height="10">
									<td></td>
								</tr>
								<tr align="center">
									<td align="center">
										请选择状态:
										<select name="chuli" size="1">
										<%
											if(session.getAttribute("flag") != null) {
	    										flag = (Boolean)session.getAttribute("flag");
	    									}
										 %>
											<option value="false" <%if(flag==false) {%>selected="selected"<%} %>>未处理</option>
											<option value="true"  <%if(flag==true) {%> selected="selected"<%} %>>已处理</option>
										</select>
										<input type="submit" value="查询" />
									</td>
								</tr>
							</table>
							<table width="90%" border="0" align="center" cellspacing="0"
								cellpadding="0">
								<tr>
									<td height="20"></td>
								</tr>
								<tr>
									<td>
										<table border="1" width="99%" align="center" cellpadding="0"
											cellspacing="1" class="resultTable">
											<tr>
												<td width="3%" height="25" align="center" bgcolor="#D9F0FF">
													寝室
												</td>
												<td width="3%" height="25" align="center" bgcolor="#D9F0FF">
													报修类型
												</td>
												<td width="7%" height="25" align="center" bgcolor="#D9F0FF">
													故障描述
												</td>
												<td width="3%" height="25" align="center" bgcolor="#D9F0FF">
													报修时间
												</td>
												<td width="3%" height="25" align="center" bgcolor="#D9F0FF">
													报修人
												</td>
												<td width="3%" height="25" align="center" bgcolor="#D9F0FF">
													电话号码
												</td>
												<td width="3%" height="25" align="center" bgcolor="#D9F0FF">
													处理人
												</td>
												<td width="3%" height="25" align="center" bgcolor="#D9F0FF">
													处理时间
												</td>
												<td width="4%" height="25" align="center" bgcolor="#D9F0FF">
													操作
												</td>
								</tr>
								<%
									int admin_id = (Integer)session.getAttribute("user_id");
									//System.out.println(admin_id);
							    	ArrayList<Fault> list = new ArrayList<Fault>();
							    	FaultControl fc = new FaultControl();
							    	list = fc.getAdminFault(admin_id,flag);
							    	PageResultSet p = new PageResultSet(list,curPage);
									ArrayList<Fault> nowlist = new ArrayList<Fault>();
									nowlist = (ArrayList<Fault>)p.getData();
									String fileName = "fault_show.jsp";
									ToolBar = p.getToolBar(fileName);
									for(int i=0; i<nowlist.size(); i++) {
										Fault fault = nowlist.get(i);
								%>
								 	<tr>
        								<td height="25" align="center"><%=fault.getDorm_name()%></td>
 										<td height="25" align="center"><%=fault.getFault_type()%></td>
 										<td height="25" align="center"><%=fault.getFault_des()%></td>
 										<td height="25" align="center"><%=fault.getFault_time()%></td>
 										<td height="25" align="center"><%=fault.getStu_name()%></td>
 										<td height="25" align="center"><%=fault.getStu_tel()%></td>	
 										<td height="25" align="center"><%=fault.getFault_reply_admin()%></td>
 										<td height="25" align="center"><%=fault.getServe_time()%></td>
 		 								<td height="25" align="center"><a href="fault_manage.jsp?id=<%=fault.getFault_id()%>">处理</a> | <a href="javascript:if(confirm('确认删除吗?'))window.location='fault_delete.jsp?id=<%=fault.getFault_id()%>'">删除</a></td>
   									</tr>
   									<%}%>
							</table>
							</td>
							</tr>
							</table>
							<%=ToolBar %>
						</form>
					</fieldset>
				</td>
			</tr>
		</table>
	</body>
</html>
